#ifndef GRIDWIDGET_H
#define GRIDWIDGET_H

#include <QtCore/QVariant>
#include <QtCore/QList>
#include <QtCore/QPoint>
#include <QtCore/QString>
#include <QtGui/QPixmap>
#include <QtGui/QWidget>

class QDragEnterEvent;
class QDropEvent;
class QMouseEvent;

class GridWidget : public QWidget {
	
	Q_OBJECT
public:
	GridWidget(QWidget *parent, int iW, int iH, QString type);
	void clear();

protected:

	void dragEnterEvent(QDragEnterEvent *event);
	//void dragLeaveEvent(QDragLeaveEvent *event);
	void dragMoveEvent(QDragMoveEvent *event);
	void dropEvent(QDropEvent *event);
	//void mousePressEvent(QMouseEvent *event);
	void paintEvent(QPaintEvent *event);

private:

	void drawGrid();
    int findPiece(const QRect &pieceRect) const;
    const QRect targetSquare(const QPoint &position) const;
    bool isValidIcon(QDropEvent *event);
    QByteArray getIconType(QDropEvent *event);

    QList<QPixmap> piecePixmaps;
    QList<QRect> pieceRects;
    QList<QPoint> pieceLocations;
    QRect highlightedRect;
	int iWidth;
	int iHeight;
	QString strType;
};

#endif
